package com.csnf.hymall.dao.imp;

import com.csnf.hymall.dao.ProductMapper;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class ProductMapperImp extends BaseMapperImp implements ProductMapper {

    @Override
    public Integer getTotalByDate(String startDate, String endDate) {
        try {
            String sql = "select count(product_id) from product where product_create_date BETWEEN ? AND ?";
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat timeSpecial = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.UK);
            Date start = simpleDateFormat.parse(startDate);
            // Date endStr = simpleDateFormat.format(endDate);

            Date endTime = timeSpecial.parse(endDate+ " 23:59:59");
            return getTotalCount(sql, start,endTime);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
